package com.imageim.yimirror.common.ui.btn;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.imageim.yimirror.R;

/**
 * Created by Bruce.Zhou on 2018/11/22 14:32.
 * Email: 907160968@qq.com
 */
public class BtnSwitchBg extends RelativeLayout {
    public BtnSwitchBg(Context context) {
        super(context);
        init();
    }

    public BtnSwitchBg(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public BtnSwitchBg(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    public BtnSwitchBg(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init();
    }

    private TextView tvTitle;
    private View vLine;

    private void init() {
        View view = View.inflate(getContext(), R.layout.btn_switch_bg, this);
        tvTitle = view.findViewById(R.id.tv_title);
        vLine = view.findViewById(R.id.v_line);
    }

    public void setSelect(boolean select) {
        if (select) {
            vLine.setVisibility(View.VISIBLE);
        } else {
            vLine.setVisibility(View.INVISIBLE);
        }
    }

    public void setTitle(String title) {
        tvTitle.setText(title);
    }
}
